import java.util.function.Consumer;
import java.util.function.Function;

/**
 * @Projectname: java8
 * @Filename: LambdaTest
 * @Author: WangYang
 * @Data:2025/3/24
 * @Description: TODO
 */
public class LambdaTest {
    public static void main(String[] args) {
        UserService u = new UserService() {
            @Override
            public String add(String a) {
                return a;
            }
        };
        System.out.println(u.add("a"));

        UserService u1 = a -> a;

        System.out.println(u1.add("a"));

        System.out.println("===============================");

        Runnable r1 = new Runnable() {
            @Override
            public void run() {
                System.out.println("111111111111");
            }
        };
        r1.run();

        Runnable r2 = () -> System.out.println("111111111111");
        r2.run();

        System.out.println("===============================");

        AddService a1 = new AddService() {
            @Override
            public void add(String a) {
                System.out.println(a);
            }
        };
        a1.add("aaaaaaaaaaaaaaa");

        AddService a2 = a ->  System.out.println(a);
        a2.add("aaaaaaaaaaaaaaa");


        System.out.println("===============================");

        Consumer<String> c1 = str -> System.out.println(str);
        c1.accept("asdadsadsadadasd");


        System.out.println("===============================");
        Consumer<String> c2 = new Consumer<String>() {
            @Override
            public void accept(String s) {

            }
        };

        Function<String,String> t = new Function<String, String>() {
            @Override
            public String apply(String s) {
                return s.toUpperCase();
            }
        };

        System.out.println(t.apply("aa"));

        System.out.println("===============================");
        System.out.println("===============================");
        System.out.println("===============================");

    }

}
